| Conditions | 1 |
| Paths | 1 |
| Total Lines | 102 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var assert = require('chai').assert, |
||
| 116 | it('Create with mixed', function(){ |
||
| 117 | var description = GedcomX.SourceDescription({ |
||
| 118 | resourceType: 'http://some/type', |
||
| 119 | citations: [ |
||
| 120 | GedcomX.SourceCitation({ |
||
| 121 | lang: 'en', |
||
| 122 | value: 'Long source citation' |
||
| 123 | }) |
||
| 124 | ], |
||
| 125 | mediaType: 'book', |
||
| 126 | about: 'http://a/resource', |
||
| 127 | mediator: { |
||
| 128 | resource: 'http://mediator' |
||
| 129 | }, |
||
| 130 | sources: [ |
||
| 131 | GedcomX.SourceReference({ |
||
| 132 | description: 'http://source/reference' |
||
| 133 | }) |
||
| 134 | ], |
||
| 135 | analysis: { |
||
| 136 | resource: 'http://analysis' |
||
| 137 | }, |
||
| 138 | componentOf: { |
||
| 139 | description: 'http://container' |
||
| 140 | }, |
||
| 141 | titles: [ |
||
| 142 | GedcomX.TextValue({ |
||
| 143 | lang: 'en', |
||
| 144 | value: 'Title' |
||
| 145 | }), |
||
| 146 | { |
||
| 147 | lang: 'es', |
||
| 148 | value: 'Titulo' |
||
| 149 | } |
||
| 150 | ], |
||
| 151 | notes: [ |
||
| 152 | GedcomX.Note({ |
||
| 153 | subject: 'Note', |
||
| 154 | text: 'Some note text' |
||
| 155 | }) |
||
| 156 | ], |
||
| 157 | attribution: { |
||
| 158 | created: 1234578129 |
||
| 159 | }, |
||
| 160 | rights: [ |
||
| 161 | GedcomX.ResourceReference({ |
||
| 162 | resource: 'https://some/right' |
||
| 163 | }) |
||
| 164 | ], |
||
| 165 | coverage: GedcomX.Coverage({ |
||
| 166 | temporal: { |
||
| 167 | formal: '+2015' |
||
| 168 | }, |
||
| 169 | spatial: { |
||
| 170 | original: 'A place' |
||
| 171 | } |
||
| 172 | }), |
||
| 173 | descriptions: [ |
||
| 174 | { |
||
| 175 | value: 'A description' |
||
| 176 | } |
||
| 177 | ], |
||
| 178 | identifiers: { |
||
| 179 | $: 'identifier' |
||
| 180 | }, |
||
| 181 | created: 1000000, |
||
| 182 | modified: 11111111, |
||
| 183 | repository: GedcomX.ResourceReference({ |
||
| 184 | resource: 'http://repository' |
||
| 185 | }) |
||
| 186 | }); |
||
| 187 | assert.equal(description.getResourceType(), 'http://some/type'); |
||
| 188 | assert.equal(description.getCitations().length, 1); |
||
| 189 | assert.equal(description.getCitations()[0].getLang(), 'en'); |
||
| 190 | assert.equal(description.getCitations()[0].getValue(), 'Long source citation'); |
||
| 191 | assert.equal(description.getMediaType(), 'book'); |
||
| 192 | assert.equal(description.getAbout(), 'http://a/resource'); |
||
| 193 | assert.equal(description.getMediator().getResource(), 'http://mediator'); |
||
| 194 | assert.equal(description.getSources().length, 1); |
||
| 195 | assert.equal(description.getSources()[0].getDescription(), 'http://source/reference'); |
||
| 196 | assert.equal(description.getAnalysis().getResource(), 'http://analysis'); |
||
| 197 | assert.equal(description.getComponentOf().getDescription(), 'http://container'); |
||
| 198 | assert.equal(description.getTitles().length, 2); |
||
| 199 | assert.equal(description.getTitles()[0].getLang(), 'en'); |
||
| 200 | assert.equal(description.getTitles()[0].getValue(), 'Title'); |
||
| 201 | assert.equal(description.getTitles()[1].getLang(), 'es'); |
||
| 202 | assert.equal(description.getTitles()[1].getValue(), 'Titulo'); |
||
| 203 | assert.equal(description.getNotes().length, 1); |
||
| 204 | assert.equal(description.getNotes()[0].getSubject(), 'Note'); |
||
| 205 | assert.equal(description.getNotes()[0].getText(), 'Some note text'); |
||
| 206 | assert.equal(description.getAttribution().getCreated().getTime(), 1234578129); |
||
| 207 | assert.equal(description.getRights().length, 1); |
||
| 208 | assert.equal(description.getRights()[0].getResource(), 'https://some/right'); |
||
| 209 | assert.equal(description.getCoverage().getTemporal().getFormal(), '+2015'); |
||
| 210 | assert.equal(description.getCoverage().getSpatial().getOriginal(), 'A place'); |
||
| 211 | assert.equal(description.getDescriptions().length, 1); |
||
| 212 | assert.equal(description.getDescriptions()[0].getValue(), 'A description'); |
||
| 213 | assert.equal(description.getIdentifiers().identifiers.$, 'identifier'); |
||
| 214 | assert.equal(description.getCreated(), 1000000); |
||
| 215 | assert.equal(description.getModified(), 11111111); |
||
| 216 | assert.equal(description.getRepository().getResource(), 'http://repository'); |
||
| 217 | }); |
||
| 218 | |||
| 289 | }); |